package com.jsyl.dao.authority;

import com.jsyl.dao.base.BaseDao;
import com.jsyl.dao.base.EntityBuiler;
import com.jsyl.dao.base.SqlBuilder;
import com.jsyl.entity.authority.ScheduleProjectSubject;
import org.springframework.stereotype.Repository;

import java.util.HashMap;
import java.util.List;
import java.util.Map;


/**
 *
 */
@Repository
public class ScheduleProjectSubjectDao extends BaseDao<ScheduleProjectSubject> {


    public List<ScheduleProjectSubject> getAbilityConfig(Integer childId, String code,Integer scheduleId) {
        StringBuilder sql = new StringBuilder();
        StringBuilder whereSql = new StringBuilder();
        sql.append(SqlBuilder.SQL_SELECT).append("*").append(SqlBuilder.SQL_FROM);
        whereSql.append("schedule_project_subject ")
                .append(SqlBuilder.SQL_WHERE).append("child_id=:childId and project_code =:code and schedule_id = :scheduleId");
        Map<String, Object> paramMap = new HashMap<String, Object>();
        paramMap.put("childId", childId);
        paramMap.put("code", code);
        paramMap.put("scheduleId", scheduleId);
        sql.append(whereSql);
        logger.info("SQL : " + "\"" + sql.toString() + "\"");
        List<Map<String, Object>> resultList = namedTemplate.queryForList(sql.toString(), paramMap);
        Map<String, String> columnMapper = new HashMap<>();
        columnMapper.putAll(tableMapper.getColumnMapper());
        return EntityBuiler.buildEntity(resultList, columnMapper, ScheduleProjectSubject.class);
    }



}

